package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始");
        try{
            String str = "null";
            System.out.println(str.length());
            String str1 = "fjqu";
            System.out.println(str1.charAt(2));
        }catch(NullPointerException e){
            System.out.println("空指针异常");
        }catch(StringIndexOutOfBoundsException e){
            System.out.println("字符串索引越界异常");
        }
        System.out.println("程序结束");
    }
}
